# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-sedlex
_pkgname=sedlex
pkgver=1.99.4
pkgrel=1
pkgdesc="An OCaml lexer generator for Unicode"
url="https://github.com/alainfrisch/sedlex"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="MIT"
depends="ocaml-gen
	ocaml-migrate-parsetree
	ocaml-ppx_tools_versioned
	ocaml-runtime
	"
makedepends="
	ocaml
	ocaml-compiler-libs
	ocaml-findlib
	ocaml-gen-dev
	ocaml-migrate-parsetree-dev
	ocaml-ppx_tools_versioned-dev
	"
subpackages="$pkgname-dev"
source="https://github.com/alainfrisch/sedlex/archive/v$pkgver/$_pkgname-$pkgver.tar.gz
	dont-build-doc.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"
	make all opt
}

check() {
	cd "$builddir"/examples
	make test
}

package() {
	cd "$builddir"

	export DESTDIR="$pkgdir"
	export OCAMLFIND_DESTDIR="$pkgdir/usr/lib/ocaml"

	mkdir -p "$OCAMLFIND_DESTDIR"
	make install
}

dev() {
	default_dev

	depends="$pkgname=$pkgver-r$pkgrel"
	local sitelib="usr/lib/ocaml/$_pkgname"

	mkdir -p "$subpkgdir"/$sitelib

	cd "$pkgdir"/$sitelib
	mv *.cmx *.cmxa "$subpkgdir"/$sitelib/
}

sha512sums="83bddb03e25b015bc71fb59e3b0e0e097e899c681c8033663c17936f28fde8599a82eaab9c26eafd645c401c106e65fcf173d9fb889eb8999eb1b064ff8b6149  sedlex-1.99.4.tar.gz
c74c51dc02596e9fbdcb18ab3aa1e0ea1bbd2361d445c74e4dea4fceb0310435bda00772272bbded338d2afb35adb819753ddd87c3b4ada28b7c77ea7414f5a5  dont-build-doc.patch"
